﻿using Autofac;
using Laugh.Data.DatabaseCfg;

namespace Laugh.Data
{
    internal class DatabaseModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>().SingleInstance();
            builder.RegisterType<DatabasePublisher>().As<IDatabasePublisher>();
            builder.RegisterGeneric(typeof(DataRepository<>)).As(typeof(IRepository<>)).InstancePerDependency();
            builder.RegisterType<SqlQuery>().As<ISqlQuery>().InstancePerLifetimeScope();
        }
    }
}
